package letcode739

func DailyTemperatures(temperatures []int) []int {
	ans := make([]int, len(temperatures))
	s := make([]int, 0)
	for i, j := range temperatures {
		for len(s) > 0 && j >= temperatures[s[len(s)-1]] {
			v := s[len(s)-1]
			s = s[:len(s)-1]
			ans[v] = i - v
		}
		s = append(s, i)
	}
	return ans
}
